package com.djz.tool.exception.category;

import com.djz.tool.exception.errorcode.CheckCode;
import lombok.Getter;
import lombok.Setter;

/**
 * 业务校对异常统一处理
 * @author djz
 */
@Getter
@Setter
public class CheckException extends RuntimeException {

    public static CheckException CHECK_EXCEPTION = new CheckException(CheckCode.SYS_OPR_SUCCESS);

    private CheckCode checkCode;

    /**
     * 状态码
     */
    private String code;

    /**
     * 对应的返回对象
     */
    private Object result;

    /**
     * 提示消息
     */
    private String msg;

    public CheckException() {
    }

    public CheckException(String code, String msg, Object result) {
        this.code = code;
        this.result = result;
        this.msg = msg;
    }

    public CheckException(CheckCode checkCode) {
        this(String.valueOf(checkCode.getCode()), checkCode.getDesc());
    }

    public CheckException(CheckCode checkCode, Object result) {
        this(String.valueOf(checkCode.getCode()), checkCode.getDesc(), result);
    }

    public CheckException(String code, String msg) {
        this(code, msg , null);
    }

    public CheckException(String code) {
        this(code, null, null);
    }

}
